/*
 * monitorstream_test.cc
 *
 *  Created on: Mar 19, 2012
 *      Author: yexijiang
 */

#include "../../src/monitor/monitorstream.h"
#include "../../src/monitor/crawler.h"
#include "../../src/monitor/manager.h"

int main(void)
{
	using namespace event;
	using namespace std;

	fprintf(stderr, "Start to monitor...\n");

	CPUCrawler *crawler1 = new CPUCrawler("cpu", -1);
	CPUCrawler *crawler2 = new CPUCrawler("cpu1", 0);

	string collector_ip = "131.94.130.167";
	int port = 32166;
	Manager manager(9000, 1.0, collector_ip, port);
	manager.Attach(crawler1);
	manager.Attach(crawler2);

	manager.StartService();

//	while(true)
//	{
//		sleep(1);
//		string crawler_name = "cpu";
//		Crawler *c = manager.GetCrawler(crawler_name);
//		ObserveData data = c->GetData();
//		fprintf(stderr, "%s:\t%f\n", TimeToString(data.timestamp).c_str(), data.value);
//	}


//
//	CPUMonitorStream *stream1 = new CPUMonitorStream("cpu", -1, 1, 5);
//	CPUMonitorStream *stream2 = new CPUMonitorStream("cpu2", 1, 1, 5);
//
//	StreamManager::AttachStream(stream1);
//	StreamManager::AttachStream(stream2);
//	StreamManager::RunStreamsInThread();
//
//	while (true)
//	{
//		sleep(2);
//		string stream_name = "cpu";
//		const MonitorStream *stream = StreamManager::GetStream(stream_name);
//		list<ObserveNode> cur_seq = stream->GetCurSequence();
//		cout << "{";
//		for (list<ObserveNode>::iterator itr = cur_seq.begin(); itr != cur_seq.end(); ++itr)
//		{
//			cout << *itr << "\t";
//		}
//		cout << "}" << endl;
//
//	}

	return 1;
}



